﻿<!DOCTYPE>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <title>热表无订单批次维护页面</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
</head>
<body>
    <div class="panelSection">
        <div class="easyui-panel " title="查询区域" style="padding: 3px;" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
            <div style="margin: 3px 0px 3px 3px">
                <div style="float: left;">
                    <div class="divLabel" style="margin-bottom: 5px">
                        订单号：</div>
                    <input id="txtMfgOrderName" class="easyui-textbox" style="width: 120px; height: 20px" />
                </div>
                <div style="float: left; margin-left: 10px">
                    <div class="divLabel" style="margin-bottom: 5px">
                        件号：</div>
                    <input id="txtProductName" class="easyui-textbox" style="width: 120px; height: 20px" />
                </div>
                <div style="float: left; margin-left: 10px">
                    <div class="divLabel" style="margin-bottom: 5px">
                        批次号：</div>
                    <input id="txtContainerName" class="easyui-textbox" style="width: 150px; height: 20px" />
                </div>
                <div style="float: left; margin-left: 10px">
                    <div class="divLabel" style="margin-bottom: 5px">
                        委托单位：</div>
                    <input id="txtEntrustUnit" class="easyui-textbox" style="width: 120px; height: 20px" />
                </div>
                <div style="float: left; margin-left: 10px">
                    <div class="divLabel" style="margin-bottom: 5px">
                        委托批次：</div>
                    <input id="txtEntrustContainer" class="easyui-textbox" style="width: 120px; height: 20px" />
                </div>
                <div style="float: left; margin-left: 20px">
                    <button id="btnSearch" class="easyui-linkbutton" data-options="" style="margin-top: 16px;
                        width: 100px">
                        查询</button>
                    <button id="btnReset" class="easyui-linkbutton" data-options="" style="margin-top: 16px;
                        margin-left: 5px; width: 60px">
                        重置</button>
                </div>
                <div style="clear: both">
                </div>
            </div>
        </div>
    </div>
    <div class="panelSection">
        <div class="easyui-panel " title="结果区域" style="padding: 3px;" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
            <div style="margin: 3px 0px 3px 3px;">
                <table id="gdContainerInfo" class="easyui-datagrid" style="width: 100%; height: 350px"
                    data-options="rownumbers:true">
                </table>
                <div id="pp" style="float: right" class="easyui-pagination" data-options="   
                 layout:['first','prev','next','last','manual','info'],              
                    total: 0,
                    showPageList: false,
                    showPageInfo: false,
                    showRefresh: false,
                    afterPageText:'共&nbsp{pages}&nbsp页',
                    buttons:[{
                            iconCls:'',
                            text:'Go',
                            id:'pageGo'
                    }]  
                ">
                </div>
            </div>
        </div>
    </div>
    <div class="panelSection">
        <div class="easyui-panel " title="按钮区域" style="padding: 3px;" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
            <div style="margin: 3px 0px 3px 3px">
                <button id="btnReceive" class="easyui-linkbutton" type="button" style="width: 120px;
                    height: 24px;">
                    任务接收</button>
                <button id="btnComplete" class="easyui-linkbutton" type="button" style="width: 120px;
                    height: 24px;">
                    完工确认</button>
                <button id="btnFollowPrint" class="easyui-linkbutton" type="button" style="width: 150px;
                    height: 24px;">
                    产品状态标识打印</button>
            </div>
        </div>
    </div>
</body>
</html>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/ReferenceJsLib.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script type="text/javascript">
    /*
    创建人：zhangrj
    日期：2023-06-02
    描述：热表无订单批次维护页面js
    */
    var page = {
        pageTotal: 0,
        pageSize: 20,
        pageNumber: 1,
        rootPath: getRootPath(), //网站根路径
        ajaxUrl: getRootPath() + "/Ashx/ReBiaoConainer/RbOrderContainerStartHandler.ashx",
        //初始化页面
        init: function () {
            page.bind();
            customizedEasyuiPagination('pp'); //定制化分页
        },
        //页面事件绑定
        bind: function () {
            //列表加载
            $("#gdContainerInfo").datagrid({
                onLoadSuccess: function (data) {
                    $('#pp').pagination('refresh', {	// 改变选项，并刷新分页栏信息
                        total: page.pageTotal,
                        pageSize: page.pageSize,
                        pageNumber: page.pageNumber
                    });
                    customizedEasyuiPagination('pp'); //定制化分页
                },
                columns: [[
                 { field: 'ck', title: '选择', checkbox: true },
                 { field: 'MFGORDERNAME', title: '订单', width: 120 },
                 { field: 'PRODUCTDESC', title: '零件名称', width: 100 },
                 { field: 'CONTAINERNAME', title: '批次', width: 200 },
                 { field: 'WORKFLOWSTEPNAME', title: '工序', width: 150 },
                 { field: 'WIPQTY', title: '在制数', width: 60 },
                 { field: 'ENTRUSTUNIT', title: '委托单位', width: 120 },
                 { field: 'ENTRUSTCONTAINER', title: '委托批次', width: 100 },
                 { field: 'RECEIVENAME', title: '任务接收人', width: 80 },
                 { field: 'RECEIVEDATE', title: '任务接收日期', width: 100,
                     formatter: function (value, row, index) {
                         if (!isNullOrWhiteSpaceStr(value)) {
                             return dayjs(value).format('YYYY-MM-DD');
                         }
                     }
                 },
                 { field: 'COMPLETENAME', title: '完工确认人', width: 80 },
                 { field: 'COMPLETEDATE', title: '完工确认日期', width: 100,
                     formatter: function (value, row, index) {
                         if (!isNullOrWhiteSpaceStr(value)) {
                             return dayjs(value).format('YYYY-MM-DD');
                         }
                     }
                 }
                ]]
            });
            //查询按钮
            $('#btnSearch').on("click", function () {
                page.pageNumber = 1;
                page.search();
            });
            //分页事件
            $('#pp').pagination({
                onSelectPage: function (pageNumber, pageSize) {
                    customizedEasyuiPagination('pp'); //定制化分页
                    page.pageSize = pageSize; page.pageNumber = pageNumber;
                    page.search();
                }
            });
            //绑定分页go按钮
            $('#pageGo').on("click", function () {
                var pageNumber = $(this).parents('tr').find('.pagination-num').val();
                page.pageNumber = pageNumber;
                page.search();
            });
            //清除按钮
            $('#btnReset').on("click", function () {
                $("#txtMfgOrderName").textbox("setValue", "");
                $("#txtProductName").textbox("setValue", "");
                $("#txtContainerName").textbox("setValue", "");
                $("#txtEntrustUnit").textbox("setValue", "");
                $("#txtEntrustContainer").textbox("setValue", "");
                clearEasyuiDataGrid("gdContainerInfo"); //清空列表
                page.pageNumber = 1; page.pagetotal = 0
                $('#pp').pagination('refresh', {
                    total: page.pageTotal,
                    pageSize: page.pageSize,
                    pageNumber: page.pageNumber
                });
            });
            //接收
            $('#btnReceive').on("click", function () {
                page.save(1);
            });
            //完成
            $('#btnComplete').on("click", function () {
                page.save(2);
            });
            //随件卡打印
            $('#btnFollowPrint').on("click", function () {
                var selected = $("#gdContainerInfo").datagrid("getChecked");
                if (selected.length === 0) {
                    displayMessage("请选择数据", false);
                    return false;
                }
                var container = selected.map(function (item) {
                    return {
                        containerID: item.CONTAINERID
                    }
                });
                page.openFollowPrint(container);
            });
        },
        //查询
        search: function () {
            clearEasyuiDataGrid("gdContainerInfo"); //清空列表
            var formData = {
                action: "GetOrderContainerMaintList",
                pageSize: page.pageSize,
                pageIndex: page.pageNumber,
                orderName: $("#txtMfgOrderName").textbox("getValue"),
                productName: $("#txtProductName").textbox("getValue"),
                containerName: $("#txtContainerName").textbox("getValue"),
                entrustUnit: $("#txtEntrustUnit").textbox("getValue"),
                entrustContainer: $("#txtEntrustContainer").textbox("getValue")
            };
            page.post(page.ajaxUrl, formData, true, function (res) {
                if (!res.Result) {
                    displayMessage(res.Message, res.Result);
                    return;
                }
                page.pageTotal = res.RowCount;
                $("#gdContainerInfo").datagrid('loadData', { total: res.RowCount, rows: res.DBTable });
            });
        },
        //保存数据（1：接收，2：完成）
        save: function (type) {
            var selected = $("#gdContainerInfo").datagrid("getChecked");
            if (selected.length === 0) {
                displayMessage("请选择数据", false);
                return false;
            }
            var container = selected.map(function (item) {
                return {
                    containerID: item.CONTAINERID,
                    containerName: item.CONTAINERNAME
                }
            });
            var datas = {
                action: "SaveRbOrderContainerReceive",
                paramDt: JSON.stringify(container),
                type: type
            }
            page.post(page.ajaxUrl, datas, true, function (res) {
                if (res.Result) {
                    page.search();
                    if (type === 1) {
                        page.openFollowPrint(container);
                    }
                }
                displayMessage(res.Message, res.Result);
            });
        },
        //打印随件卡
        openFollowPrint: function (data) {
            var url = "/InSiteWebApplication/forms/Custom/ReBiao/RbContainerInfoFollowPrintPage.html?formID=2&formData=" + JSON.stringify(data);
            window.open(url);
        },
        //post数据（路径，参数，是否异步，成功返回方法）
        post: function (url, param, async, callback) {
            $.ajax({
                type: "Post",
                url: url,
                data: param,
                cashe: false,
                async: async,
                dataType: "json",
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    callback(data);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    displayMessage(XMLHttpRequest.responseText, false);
                    $("body").find(".easyui-linkbutton").each(function () {
                        $(this).linkbutton('enable');
                    });
                }
            });
        }
    }
    $(function () {
        page.init();
    });
</script>
